package qe.spider.trade.huaxin;

import java.io.IOException;
import java.util.Date;
import java.text.SimpleDateFormat;

import com.tora.lev2mdapi.*;


class Lev2DemoSpi extends CTORATstpLev2MdSpi {
    static String Front_Address = "tcp://10.0.1.101:6900";
    static String Multicast_Address = "udp://224.224.224.234:7889";
    static String Multicast_Address2 = "udp://224.224.224.234:7890";
    static String Local_Interface_Address = "10.0.1.24";
    static String Sender_Interface_Address = "10.0.1.101";

    static boolean g_SubMarketData = true;  //快照行情
    static boolean g_SubTransaction = true; //逐笔成交
    static boolean g_SubOrderDetail = true; //逐笔委托
    static boolean g_SubXTSTick = true; //Lev2债券逐笔行情(上海)
    static boolean g_SubXTSMarketData = true;
    static boolean g_SubNGTSTick = true;//非债券类Lev2逐笔行情(上海)
    static boolean g_SubBondMarketData = true;
    static boolean g_SubBondTransaction = true;
    static boolean g_SubBondOrderDetail = true;

    //    00000000 是全市场订阅
    //    600***   是订阅600开头的股票
    //    605358   是订阅605358个股
    static String SH_Securities[] = {"51****", "600***", "00000000"};
    static String SH_XTS_Securities[] = {"018003", "113565", "00000000"};

    static String SZ_Securities[] = {"000001", "128***", "00000000"};
    static String SZ_Bond_Securities[] = {"100303", "109***", "112617", "00000000"};


    CTORATstpLev2MdApi m_api;
    int m_request_id;

    public Lev2DemoSpi(CTORATstpLev2MdApi api) {
        m_api = api;
        m_request_id = 0;
    }

    public void OnFrontConnected() {
        System.out.printf("OnFrontConnected\n");

        CTORATstpReqUserLoginField req_user_login_field = new CTORATstpReqUserLoginField();

        int ret = m_api.ReqUserLogin(req_user_login_field, ++m_request_id);
        if (ret != 0) {
            System.out.printf("ReqUserLogin fail, ret[%d]\n", ret);
        }
    }

    public void OnFrontDisconnected(int nReason) {
        System.out.printf("OnFrontDisconnected, reason[%d]\n", nReason);
    }

    public void OnRspUserLogin(CTORATstpRspUserLoginField pRspUserLogin, CTORATstpRspInfoField pRspInfo, int nRequestID, boolean bIsLast) {
        if (pRspInfo.getErrorID() == 0) {
            System.out.printf("login success!\n");


            if (g_SubMarketData) {  //快照行情
//                m_api.SubscribeMarketData(SH_Securities, lev2mdapi.getTORA_TSTP_EXD_SSE());
//                m_api.SubscribeMarketData(SZ_Securities, lev2mdapi.getTORA_TSTP_EXD_SZSE());
                m_api.SubscribeMarketData(new String[]{"605358"}, lev2mdapi.getTORA_TSTP_EXD_SSE());
                m_api.SubscribeMarketData(new String[]{"002351"}, lev2mdapi.getTORA_TSTP_EXD_SZSE());
            }


//            if (g_SubTransaction) {   //逐笔成交
////                m_api.SubscribeTransaction(SH_Securities, lev2mdapi.getTORA_TSTP_EXD_SSE());
////                m_api.SubscribeTransaction(SZ_Securities, lev2mdapi.getTORA_TSTP_EXD_SZSE());
//                m_api.SubscribeTransaction(new String[]{"600***", "00000000"}, lev2mdapi.getTORA_TSTP_EXD_SSE());
//                m_api.SubscribeTransaction(new String[]{"00****", "30****", "00000000"}, lev2mdapi.getTORA_TSTP_EXD_SZSE());
//            }
//
//            if (g_SubOrderDetail) {   //逐笔委托
////                m_api.SubscribeOrderDetail(SH_Securities, lev2mdapi.getTORA_TSTP_EXD_SSE());
////                m_api.SubscribeOrderDetail(SZ_Securities, lev2mdapi.getTORA_TSTP_EXD_SZSE());
//                m_api.SubscribeOrderDetail(new String[]{"00000000"}, lev2mdapi.getTORA_TSTP_EXD_SSE());
//                m_api.SubscribeOrderDetail(new String[]{"00****","30****"}, lev2mdapi.getTORA_TSTP_EXD_SZSE());
//            }
//
//            if (g_SubXTSTick) {   //债券类逐笔行情
//                m_api.SubscribeXTSTick(SH_XTS_Securities, lev2mdapi.getTORA_TSTP_EXD_SSE());
//            }
//
//
//            if (g_SubXTSMarketData) {
//                m_api.SubscribeXTSMarketData(SH_XTS_Securities, lev2mdapi.getTORA_TSTP_EXD_SSE());
//            }
//
//
//            if (g_SubBondMarketData) {
//                m_api.SubscribeBondMarketData(SZ_Bond_Securities, lev2mdapi.getTORA_TSTP_EXD_SZSE());
//            }
//
//            if (g_SubBondTransaction) {
//                m_api.SubscribeBondTransaction(SZ_Bond_Securities, lev2mdapi.getTORA_TSTP_EXD_SZSE());
//            }
//
//            if (g_SubBondOrderDetail) {
//                m_api.SubscribeBondOrderDetail(SZ_Bond_Securities, lev2mdapi.getTORA_TSTP_EXD_SZSE());
//            }
//
            //4.0.5版本支持接口 非债券类逐笔行情（上海），仿真环境为历史某日行情24小时轮播
//            if (g_SubNGTSTick) {
////                m_api.SubscribeNGTSTick(SH_Securities, lev2mdapi.getTORA_TSTP_EXD_SSE());
//                m_api.SubscribeNGTSTick(new String[]{"605358"}, lev2mdapi.getTORA_TSTP_EXD_SSE());
//            }
        } else {
            System.out.printf("login fail, error_id[%d] error_msg[%s]!!!\n", pRspInfo.getErrorID(), pRspInfo.getErrorMsg());
        }
    }

    public void OnRspSubMarketData(CTORATstpSpecificSecurityField pSpecificSecurity, CTORATstpRspInfoField pRspInfo, int nRequestID, boolean bIsLast) {
        if (pRspInfo.getErrorID() == 0) {
            System.out.printf("subscribe market data success!\n");
        } else {
            System.out.printf("subscribe market data fail, error_id[%d] error_msg[%s]!\n", pRspInfo.getErrorID(), pRspInfo.getErrorMsg());
        }
    }

    public void OnRspSubXTSMarketData(CTORATstpSpecificSecurityField pSpecificSecurity, CTORATstpRspInfoField pRspInfo, int nRequestID, boolean bIsLast) {
        if (pRspInfo.getErrorID() == 0) {
            System.out.printf("subscribe xts market data success!\n");
        } else {
            System.out.printf("subscribe xts market data fail, error_id[%d] error_msg[%s]!\n", pRspInfo.getErrorID(), pRspInfo.getErrorMsg());
        }
    }

    public void OnRspSubBondMarketData(CTORATstpSpecificSecurityField pSpecificSecurity, CTORATstpRspInfoField pRspInfo, int nRequestID, boolean bIsLast) {
        if (pRspInfo.getErrorID() == 0) {
            System.out.printf("subscribe bond market data success!\n");
        } else {
            System.out.printf("subscribe bond market data fail, error_id[%d] error_msg[%s]!\n", pRspInfo.getErrorID(), pRspInfo.getErrorMsg());
        }
    }

    public void OnRspSubIndex(CTORATstpSpecificSecurityField pSpecificSecurity, CTORATstpRspInfoField pRspInfo, int nRequestID, boolean bIsLast) {
        if (pRspInfo.getErrorID() == 0) {
            System.out.printf("subscribe index success!\n");
        } else {
            System.out.printf("subscribe index fail, error_id[%d] error_msg[%s]!\n", pRspInfo.getErrorID(), pRspInfo.getErrorMsg());
        }
    }

    public void OnRspSubTransaction(CTORATstpSpecificSecurityField pSpecificSecurity, CTORATstpRspInfoField pRspInfo, int nRequestID, boolean bIsLast) {
        if (pRspInfo.getErrorID() == 0) {
            System.out.printf("subscribe transaction success!\n");
        } else {
            System.out.printf("subscribe transaction fail, error_id[%d] error_msg[%s]!\n", pRspInfo.getErrorID(), pRspInfo.getErrorMsg());
        }
    }

    public void OnRspSubOrderDetail(CTORATstpSpecificSecurityField pSpecificSecurity, CTORATstpRspInfoField pRspInfo, int nRequestID, boolean bIsLast) {
        if (pRspInfo.getErrorID() == 0) {
            System.out.printf("subscribe order detail 逐笔委托 success!\n");
        } else {
            System.out.printf("subscribe order detail fail, error_id[%d] error_msg[%s]!\n", pRspInfo.getErrorID(), pRspInfo.getErrorMsg());
        }
    }

    public void OnRspSubBondTransaction(CTORATstpSpecificSecurityField pSpecificSecurity, CTORATstpRspInfoField pRspInfo, int nRequestID, boolean bIsLast) {
        if (pRspInfo.getErrorID() == 0) {
            System.out.printf("subscribe bond transaction 逐笔成交 success!\n");
        } else {
            System.out.printf("subscribe bond transaction fail, error_id[%d] error_msg[%s]!\n", pRspInfo.getErrorID(), pRspInfo.getErrorMsg());
        }
    }

    public void OnRspSubBondOrderDetail(CTORATstpSpecificSecurityField pSpecificSecurity, CTORATstpRspInfoField pRspInfo, int nRequestID, boolean bIsLast) {
        if (pRspInfo.getErrorID() == 0) {
            System.out.printf("subscribe bond order detail success!\n");
        } else {
            System.out.printf("subscribe bond order detail fail, error_id[%d] error_msg[%s]!\n", pRspInfo.getErrorID(), pRspInfo.getErrorMsg());
        }
    }

    public void OnRspSubXTSTick(CTORATstpSpecificSecurityField pSpecificSecurity, CTORATstpRspInfoField pRspInfo, int nRequestID, boolean bIsLast) {
        if (pRspInfo.getErrorID() == 0) {
            System.out.printf("subscribe xts tick success!\n");
        } else {
            System.out.printf("subscribe xts tick fail, error_id[%d] error_msg[%s]!\n", pRspInfo.getErrorID(), pRspInfo.getErrorMsg());
        }
    }


    //4。0.5版本接口
    public void OnRspSubNGTSTick(CTORATstpSpecificSecurityField pSpecificSecurity, CTORATstpRspInfoField pRspInfo, int nRequestID, boolean bIsLast) {
        if (pRspInfo.getErrorID() == 0) {
            System.out.printf("subscribe ngts tick success!\n");
        } else {
            System.out.printf("subscribe ngts tick fail, error_id[%d] error_msg[%s]!\n", pRspInfo.getErrorID(), pRspInfo.getErrorMsg());
        }
    }


    public void OnRtnMarketData(CTORATstpLev2MarketDataField pMarketData, int FirstLevelBuyNum, SWIGTYPE_p_int FirstLevelBuyOrderVolumes, int FirstLevelSellNum, SWIGTYPE_p_int FirstLevelSellOrderVolumes) {
        System.out.printf("======OnRtnMarketData=========非债券类快照行情\n");
        System.out.printf("行情交易所代码 ExchangeID[%c]\n", pMarketData.getExchangeID());
        System.out.printf("证券代码 SecurityID[%s]\n", pMarketData.getSecurityID());
        System.out.printf("时间戳 DataTimeStamp[%d]\n", pMarketData.getDataTimeStamp());
        System.out.printf("现价 LastPrice[%.3f]\n", pMarketData.getLastPrice());
        System.out.printf("成交总量 TotalVolumeTrade[%d]\n", pMarketData.getTotalVolumeTrade());
        System.out.printf("成交总金额 TotalValueTrade[%.3f]\n", pMarketData.getTotalValueTrade());
        System.out.printf("申买价一 BidPrice1[%.3f]\n", pMarketData.getBidPrice1());
        System.out.printf("申买量一 BidVolume1[%d]\n", pMarketData.getBidVolume1());
        System.out.printf("申卖价一 AskPrice1[%.3f]\n", pMarketData.getAskPrice1());
        System.out.printf("申卖量一 AskVolume1[%d]\n", pMarketData.getAskVolume1());

        System.out.printf("FirstLevelBuyNum[%d]: ", FirstLevelBuyNum);
        for (int i = 0; i < FirstLevelBuyNum; i++) {
            System.out.printf("%d ", lev2mdapi.get_value(FirstLevelBuyOrderVolumes, i));
        }
        System.out.printf("\n");

        System.out.printf("FirstLevelSellNum[%d]: ", FirstLevelSellNum);
        for (int i = 0; i < FirstLevelSellNum; i++) {
            System.out.printf("%d ", lev2mdapi.get_value(FirstLevelSellOrderVolumes, i));
        }
        System.out.printf("\n\n");
    }

    public void OnRtnIndex(CTORATstpLev2IndexField pIndex) {
        System.out.printf("=======OnRtnIndex======指数\n");
        System.out.printf("ExchangeID[%c]\n", pIndex.getExchangeID());
        System.out.printf("SecurityID[%s]\n", pIndex.getSecurityID());
        System.out.printf("LastIndex[%.3f]\n\n", pIndex.getLastIndex());
    }

    public void OnRtnTransaction(CTORATstpLev2TransactionField pTransaction) {
        System.out.printf("=======OnRtnTransaction======非债券类逐笔行情（成交）\n");
        System.out.printf("交易所代码 ExchangeID[%c]\n", pTransaction.getExchangeID());
        System.out.printf("证券代码 SecurityID[%s]\n", pTransaction.getSecurityID());
        System.out.printf("时间戳 TradeTime[%d]\n", pTransaction.getTradeTime());
        System.out.printf("成交价格 TradePrice[%.3f]\n", pTransaction.getTradePrice());
        System.out.printf("成交数量 TradeVolume[%d]\n", pTransaction.getTradeVolume());
        System.out.printf("成交类别（只有深圳行情有效） ExecType[%c]\n", pTransaction.getExecType());
        System.out.printf("主序号 MainSeq[%d]\n", pTransaction.getMainSeq());
        System.out.printf("子序号 Subseq[%d]\n", pTransaction.getSubSeq());
        System.out.printf("买方委托序号 BuyNo[%d]\n", pTransaction.getBuyNo());
        System.out.printf("卖方委托序号 SellNo[%d]\n\n", pTransaction.getSellNo());
    }

    public void OnRtnOrderDetail(CTORATstpLev2OrderDetailField pOrderDetail) {
        System.out.printf("=======OnRtnOrderDetail======非债券类逐笔行情(委托)\n");
        System.out.printf("交易所代码 ExchangeID[%c]\n", pOrderDetail.getExchangeID());
        System.out.printf("证券代码 SecurityID[%s]\n", pOrderDetail.getSecurityID());
        System.out.printf("时间戳 OrderTime[%d]\n", pOrderDetail.getOrderTime());
        System.out.printf("委托价格 Price[%.3f]\n", pOrderDetail.getPrice());
        System.out.printf("委托数量 Volume[%d]\n", pOrderDetail.getVolume());
        System.out.printf("委托方向 Side[%c]\n", pOrderDetail.getSide());
        System.out.printf("订单类别（只有深圳行情有效） OrderType[%c]\n", pOrderDetail.getOrderType());
        System.out.printf("主序号 MainSeq[%d]\n", pOrderDetail.getMainSeq());
        System.out.printf("子序号 Subseq[%d]\n", pOrderDetail.getSubSeq());
        System.out.printf("附加信息1 Info1[%d]\n", pOrderDetail.getInfo1());
        System.out.printf("附加信息2 Info2[%d]\n", pOrderDetail.getInfo2());
        System.out.printf("附加信息3 Info3[%d]\n", pOrderDetail.getInfo3());
        System.out.printf("委托序号 OrderNO[%d]\n", pOrderDetail.getOrderNO());
        System.out.printf("订单状态 OrderStatus[%c]\n", pOrderDetail.getOrderStatus());
        System.out.printf("业务序号（只有上海行情有效） BizIndex[%d]\n\n", pOrderDetail.getBizIndex());
    }


    public void OnRtnXTSMarketData(CTORATstpLev2XTSMarketDataField pMarketData, int FirstLevelBuyNum, SWIGTYPE_p_int FirstLevelBuyOrderVolumes, int FirstLevelSellNum, SWIGTYPE_p_int FirstLevelSellOrderVolumes) {
        System.out.printf("======OnRtnXTSMarketData=========债券类快照行情\n");
        System.out.printf("ExchangeID[%c]\n", pMarketData.getExchangeID());
        System.out.printf("SecurityID[%s]\n", pMarketData.getSecurityID());
        System.out.printf("LastPrice[%.3f]\n", pMarketData.getLastPrice());
        System.out.printf("TotalVolumeTrade[%d]\n", pMarketData.getTotalVolumeTrade());
        System.out.printf("TotalValueTrade[%.3f]\n", pMarketData.getTotalValueTrade());
        System.out.printf("BidPrice1[%.3f]\n", pMarketData.getBidPrice1());
        System.out.printf("BidVolume1[%d]\n", pMarketData.getBidVolume1());
        System.out.printf("AskPrice1[%.3f]\n", pMarketData.getAskPrice1());
        System.out.printf("AskVolume1[%d]\n", pMarketData.getAskVolume1());

        System.out.printf("FirstLevelBuyNum[%d]: ", FirstLevelBuyNum);
        for (int i = 0; i < FirstLevelBuyNum; i++) {
            System.out.printf("%d ", lev2mdapi.get_value(FirstLevelBuyOrderVolumes, i));
        }
        System.out.printf("\n");

        System.out.printf("FirstLevelSellNum[%d]: ", FirstLevelSellNum);
        for (int i = 0; i < FirstLevelSellNum; i++) {
            System.out.printf("%d ", lev2mdapi.get_value(FirstLevelSellOrderVolumes, i));
        }
        System.out.printf("\n\n");
    }


    public void OnRtnXTSTick(CTORATstpLev2XTSTickField ptick) {
        System.out.printf("=======OnRtnXTSTick======债券类逐笔行情\n");
        System.out.printf("ExchangeID[%c]\n", ptick.getExchangeID());
        System.out.printf("SecurityID[%s]\n", ptick.getSecurityID());
        System.out.printf("Price[%.3f]\n", ptick.getPrice());
        System.out.printf("Volume[%d]\n", ptick.getVolume());
        System.out.printf("TickTime[%d]\n", ptick.getTickTime());
        System.out.printf("TickType[%c]\n", ptick.getTickType());
        System.out.printf("MainSeq[%d]\n", ptick.getMainSeq());
        System.out.printf("Subseq[%d]\n\n", ptick.getSubSeq());
    }

    //4.0.5版本接口
    public void OnRtnNGTSTick(CTORATstpLev2NGTSTickField ptick) {
        System.out.printf("=======OnRtnNGTSTick======非债券类逐笔行情（上海）\n");
        System.out.printf("交易所代码 ExchangeID[%c]\n", ptick.getExchangeID());
        System.out.printf("证券代码 SecurityID[%s]\n", ptick.getSecurityID());
        System.out.printf("价格 Price[%.3f]\n", ptick.getPrice());
        System.out.printf("数量 Volume[%d]\n", ptick.getVolume());
        System.out.printf("时间戳 TickTime[%d]\n", ptick.getTickTime());
        System.out.printf("逐笔类型 TickType[%c]\n", ptick.getTickType());
        System.out.printf("主序号 MainSeq[%d]\n", ptick.getMainSeq());
        System.out.printf("子序号 Subseq[%d]\n", ptick.getSubSeq());
        System.out.printf("委托方向 Side[%c]\n", ptick.getSide());
        System.out.printf("内外盘标志 TradeBSFlag[%c]\n", ptick.getTradeBSFlag());
        System.out.printf("行情产品实时状态 MDSecurityStat[%c]\n", ptick.getMDSecurityStat());
        System.out.printf("成交金额或新增委托订单已成交委托量 TradeMoney[%.3f]\n\n", ptick.getTradeMoney());
    }


    public void OnRtnBondMarketData(CTORATstpLev2BondMarketDataField pMarketData, int FirstLevelBuyNum, SWIGTYPE_p_int FirstLevelBuyOrderVolumes, int FirstLevelSellNum, SWIGTYPE_p_int FirstLevelSellOrderVolumes) {
        System.out.printf("======OnRtnBondMarketData=========债券类快照行情\n");
        System.out.printf("ExchangeID[%c]\n", pMarketData.getExchangeID());
        System.out.printf("SecurityID[%s]\n", pMarketData.getSecurityID());
        System.out.printf("LastPrice[%.3f]\n", pMarketData.getLastPrice());
        System.out.printf("TotalVolumeTrade[%d]\n", pMarketData.getTotalVolumeTrade());
        System.out.printf("TotalValueTrade[%.3f]\n", pMarketData.getTotalValueTrade());
        System.out.printf("BidPrice1[%.3f]\n", pMarketData.getBidPrice1());
        System.out.printf("BidVolume1[%d]\n", pMarketData.getBidVolume1());
        System.out.printf("AskPrice1[%.3f]\n", pMarketData.getAskPrice1());
        System.out.printf("AskVolume1[%d]\n", pMarketData.getAskVolume1());

        System.out.printf("FirstLevelBuyNum[%d]: ", FirstLevelBuyNum);
        for (int i = 0; i < FirstLevelBuyNum; i++) {
            System.out.printf("%d ", lev2mdapi.get_value(FirstLevelBuyOrderVolumes, i));
        }
        System.out.printf("\n");

        System.out.printf("FirstLevelSellNum[%d]: ", FirstLevelSellNum);
        for (int i = 0; i < FirstLevelSellNum; i++) {
            System.out.printf("%d ", lev2mdapi.get_value(FirstLevelSellOrderVolumes, i));
        }
        System.out.printf("\n\n");
    }

    public void OnRtnBondTransaction(CTORATstpLev2BondTransactionField pTransaction) {
        System.out.printf("=======OnRtnBondTransaction======债券类逐笔成交\n");
        System.out.printf("ExchangeID[%c]\n", pTransaction.getExchangeID());
        System.out.printf("SecurityID[%s]\n", pTransaction.getSecurityID());
        System.out.printf("TradePrice[%.3f]\n", pTransaction.getTradePrice());
        System.out.printf("TradeVolume[%d]\n", pTransaction.getTradeVolume());
        System.out.printf("ExecType[%c]\n", pTransaction.getExecType());
        System.out.printf("MainSeq[%d]\n", pTransaction.getMainSeq());
        System.out.printf("Subseq[%d]\n", pTransaction.getSubSeq());
        System.out.printf("BuyNo[%d]\n", pTransaction.getBuyNo());
        System.out.printf("SellNo[%d]\n\n", pTransaction.getSellNo());
    }

    public void OnRtnBondOrderDetail(CTORATstpLev2BondOrderDetailField pOrderDetail) {
        System.out.printf("=======OnRtnBondOrderDetail======债券类逐笔行情\n");
        System.out.printf("ExchangeID[%c]\n", pOrderDetail.getExchangeID());
        System.out.printf("SecurityID[%s]\n", pOrderDetail.getSecurityID());
        System.out.printf("Price[%.3f]\n", pOrderDetail.getPrice());
        System.out.printf("Volume[%d]\n", pOrderDetail.getVolume());
        System.out.printf("Side[%c]\n", pOrderDetail.getSide());
        System.out.printf("OrderType[%c]\n", pOrderDetail.getOrderType());
        System.out.printf("MainSeq[%d]\n", pOrderDetail.getMainSeq());
        System.out.printf("Subseq[%d]\n\n", pOrderDetail.getSubSeq());
    }
}


/**
 * @author 86158
 */
class Lev2MdApiTest {
    static {
        System.loadLibrary("./lib/huaxin/x64/javalev2mdapi");
    }

    public static void main(String[] args) throws IOException, InterruptedException {
        System.out.printf("Version[%s]\n", CTORATstpLev2MdApi.GetApiVersion());

        //非缓存模式
        boolean bcache = false;
        //缓存模式
        //boolean bcache=true;

        //tcp收行情
        char MDSubMode = lev2mdapi.getTORA_TSTP_MST_TCP();
        //组播收行情
        //char MDSubMode = lev2mdapi.getTORA_TSTP_MST_MCAST();

        CTORATstpLev2MdApi api = CTORATstpLev2MdApi.CreateTstpLev2MdApi(MDSubMode, bcache);

        Lev2DemoSpi spi = new Lev2DemoSpi(api);
        api.RegisterSpi(spi);

        if (MDSubMode != lev2mdapi.getTORA_TSTP_MST_MCAST()) {
            //注册tcp行情服务地址（示例地址仅为Lev2测试桩地址，生产上请自行修改）
//            深圳Level2：tcp://210.14.72.17:6900
//            上海Level2：tcp://210.14.72.17:16900
//            api.RegisterFront("tcp://210.14.72.17:16900");//Level 1 行情&交易：tcp://210.14.72.21:4402
            api.RegisterFront("tcp://210.14.72.17:6900");//Level 1 行情&交易：tcp://210.14.72.21:4402
        } else {
            //case 1:从一个组播地址收取行情
            api.RegisterMulticast("udp://232.224.224.231:7895", "192.168.0.193", "192.168.0.192");

            //case 2:注册多个组播地址同时收行情
            //api.RegisterMulticast("udp://232.224.224.231:7895","192.168.0.193","192.168.0.192");
            //api.RegisterMulticast("udp://232.224.224.231:7896","192.168.0.193","192.168.0.192");
            //api.RegisterMulticast("udp://232.224.224.231:7897","192.168.0.193","192.168.0.192");

            //case 3:注册多个组播地址采取efvi模式同时收行情
            //api.RegisterMulticast("udp://232.224.224.231:7895","192.168.0.193","192.168.0.192","enp101s0f0",4096,true);
            //api.RegisterMulticast("udp://232.224.224.231:7896","192.168.0.193","192.168.0.192","enp101s0f0",4096,true);
            //api.RegisterMulticast("udp://232.224.224.231:7897","192.168.0.193","192.168.0.192","enp101s0f0",4096,true);
        }


        //case 1:不绑核运行
        api.Init();
        //case 2:绑定指定核运行
        //api.Init("2,17");

        System.in.read();

//        api.Release();

        System.out.printf("Exit...\n");
    }
}
